package com.zlp.spring.v5.config;
import com.zlp.spring.v5.entity.Person;
import org.springframework.beans.factory.FactoryBean;

public class MyFactoryBean implements FactoryBean {


    private String initStr;

    public MyFactoryBean(String initStr) {
        this.initStr = initStr;
    }

    /**
     * 获取Bean返回对象
     * @date: 2021/2/26 11:35
     * @return: java.lang.Object 
     */
    public Object getObject() throws Exception {

        //这里我需要获取对应参数
        String[] split = initStr.split(",");
        Person person =new Person();
        person.setAge(Integer.parseInt(split[0]));
        person.setUserName(split[1]);
        return person;
    }

    public Class getObjectType() {
        return Person.class;
    }

    public boolean isSingleton() {
        return true;
    }

    public String getInitStr() {
        return initStr;
    }



}
